from setenv import setLotteryDir
from setenv import getFileDir
from setenv import getFileName


ss_gd_red={}
ss_gd_blue={}
guize={}
ss_sj_red={}
ss_sj_blue={}
filedir=""
ssqfilename=""


def pp(dic):
    for i in dic.keys():
        if dic[i] :
          print( str(i) ,end = " ")



def csh():
    global ss_gd_red
    global ss_gd_blue
    global guize

    for i in range(1, 34):
        ss_gd_red[i] = False
    for i in range(1, 17):
        ss_gd_blue[i] = False
    ss_gd_red[3] = True
    ss_gd_red[12] = True
    ss_gd_red[21] = True
    ss_gd_red[25] = True
    ss_gd_red[27] = True
    ss_gd_red[29] = True
    ss_gd_blue[4] = True
    guize[0] = "未中奖"
    guize[10] = "未中奖"
    guize[20] = "未中奖"
    guize[30] = "未中奖"
    guize[40] = "五等奖"
    guize[50] = "四等奖"
    guize[60] = "二等奖"
    guize[1]  = "六等奖"
    guize[11] = "六等奖"
    guize[21] = "六等奖"
    guize[31] = "五等奖"
    guize[41] = "四等奖"
    guize[51] = "三等奖"
    guize[61] = "一等奖"

    setLotteryDir()
    global filedir
    filedir = getFileDir()
    global ssqfilename
    ssqfilename = getFileName("ssqfilename")
    print(filedir)
    print(ssqfilename)

def csh_sj():
    for i in range(1, 34):
        ss_sj_red[i] = False
    for i in range(1, 17):
        ss_sj_blue[i] = False

    with open(str(filedir) + "/ss-sj.txt","r") as file:
        ss_sj = file.read().strip().split(" ")
    file.close
#    print(str(ss_sj))
    for i in range(1,7):
        ss_sj_red[int(ss_sj[i-1])] = True
    ss_sj_blue[int(ss_sj[6])] = True

def bijiao():
    with open( str(filedir) + "/" + str(ssqfilename), "r") as file:
        # 写入数据
        num = file.read().strip().split(" ")

    file.close
    print(num)

    red = 0
    for i in range(1,7):
        if ss_gd_red[int(num[i-1])] :
            red += 1
    blue = 0
    if ss_gd_blue[int(num[6])] :
        blue += 1

    result = int(str(red) + str(blue))
    pp(ss_gd_red)
    pp(ss_gd_blue)
    print("red：" + str(red) + "，blue：" + str(blue) + "。结论：" + guize[result])

def bijiao_sj():
    with open( str(filedir) + "/" + str(ssqfilename), "r") as file:
        # 写入数据
        num = file.read().strip().split(" ")

    file.close
    print(num)

    red = 0
    for i in range(1,7):
        if ss_sj_red[int(num[i-1])] :
            red += 1
    blue = 0
    if ss_sj_blue[int(num[6])] :
        blue += 1

    result = int(str(red) + str(blue))
    pp(ss_sj_red)
    pp(ss_sj_blue)
    print("red：" + str(red) + "，blue：" + str(blue) + "。结论：" + guize[result])



if __name__ == '__main__':

     csh()
     bijiao()
     csh_sj()
     bijiao_sj()